<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 使用var声明的变量，会被提升到前面。变量a的值使undefined，而不是报异常：Uncaught ReferenceError: a is not defined
        // console.log(a);  
        // var a = 1;
        // console.log(a);

        // 以上代码等同于
        var a;
        console.log(a);
        a = 1;
        console.log(a);

        // if中的var变量提升
        var web = "houdunren";
        function hd() {
            if (false) {
                var web = "后盾人";
            }
            console.log(web);
        }
        hd();

    </script>
</body>

</html>